const { BaseCommand } = require("./base");

class MysqlConnectCommand extends BaseCommand {
    async execute() {
        const data = this.selfData;
        var mysql = require("mysql");
        var connection = mysql.createConnection({
            host: data.host ?? "localhost",
            port: data.port ?? 3306,
            password: data.password ?? "",
            user: data.user,
            database: data.database,
        });

        connection.connect();

        // connection.query('SELECT * FROM zt_task LIMIT 10', function (error, results, fields) {
        // if (error) throw error;
        // console.log('The solution is: ', results[0].solution);
        // });

        // connection.end();
        return connection;
    }
}

module.exports = {
    MysqlConnectCommand,
};
